package com.hmy.finance.client;

import com.hmy.ccp.common.result.FeignResult;
import com.hmy.ccp.common.result.Results;
import com.hmy.ccp.error.annotations.HmyFeignController;
import com.hmy.finance.api.bo.core.request.*;
import com.hmy.finance.api.bo.core.request.vos.DeviceInfoVo;
import com.hmy.finance.api.bo.core.response.*;
import com.hmy.finance.service.core.IFinancialCoreDataService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.groups.Default;

/**
 * 核心数据-Feign
 *
 * @author songkf
 */
@RestController
@HmyFeignController
public class FinancialCoreClientController {
    @Resource
    private IFinancialCoreDataService financialCoreDataService;

    /**
     * 开始租赁
     *
     * @param request 请求
     * @return 结果
     */
    @PostMapping("/feign/finance/core/startRental")
    public FeignResult<StartRentalResponse> startRental(@RequestBody StartRentalRequest request) {
        return Results.newSuccessResult(financialCoreDataService.startRental(request));
    }

    /**
     * 终止租赁
     *
     * @param request 请求
     * @return 结果
     */
    @PostMapping("/feign/finance/core/terminationRental")
    public FeignResult<TerminationRentalResponse> terminationRental(@RequestBody TerminationRentalRequest request) {
        return Results.newSuccessResult(financialCoreDataService.terminationRental(request));
    }

    /**
     * 应收调整损益生成
     *
     * @param request 请求
     * @return 结果
     */
    @PostMapping("/feign/finance/core/rentalAdjustmentProfitLoss")
    public FeignResult<BaseGenerateProfitLossResponse> receivableAdjustmentProfitLoss(@RequestBody ReceivableAdjustGenerateRequest request) {
        return Results.newSuccessResult(financialCoreDataService.rentalAdjustmentProfitLoss(request));
    }

    /**
     * 索赔损益生成
     *
     * @param request 请求
     * @return 结果
     */
    @PostMapping("/feign/finance/core/claimGenerateProfitLoss")
    public FeignResult<BaseGenerateProfitLossResponse> claimGenerateProfitLoss(@RequestBody ClaimGenerateRequest request) {
        return Results.newSuccessResult(financialCoreDataService.claimGenerateProfitLoss(request));
    }

    /**
     * 报停损益生成
     *
     * @param request 请求
     * @return 结果
     */
    @PostMapping("/feign/finance/core/pauseGenerateProfitLoss")
    public FeignResult<BaseGenerateProfitLossResponse> pauseGenerateProfitLoss(@RequestBody PauseGenerateRequest request) {
        return Results.newSuccessResult(financialCoreDataService.pauseGenerateProfitLoss(request));
    }

    /**
     * 查询设备租赁记录剩余暂停天数
     *
     * @param request 请求参数
     * @return 响应结果
     * @author songkf
     */
    @PostMapping("/feign/finance/core/queryDeviceRentalRecordRemainingPauseDay")
    public FeignResult<QueryDeviceRentalRecordRemainingPauseDayResponse> queryDeviceRentalRecordRemainingPauseDay(@RequestBody QueryDeviceRentalRecordRemainingPauseDayRequest request) {
        return Results.newSuccessResult(financialCoreDataService.queryDeviceRentalRecordRemainingPauseDay(request));
    }

    /**
     * 合同退场停止流水和冲抵
     *
     * @param request 请求
     * @return 结果
     */
    @PostMapping("/feign/finance/core/contractTerminationStopFlowAndOffset")
    public FeignResult<ContractTerminationStopFlowAndOffsetResponse> contractTerminationStopFlowAndOffset(@RequestBody ContractTerminationStopFlowAndOffsetRequest request) {
        return Results.newSuccessResult(financialCoreDataService.contractTerminationStopFlowAndOffset(request));
    }

    /**
     * 合同取消停止流水和冲抵
     *
     * @param request 请求
     * @return 结果
     */
    @PostMapping("/feign/finance/core/contractCancelStopFlowAndOffset")
    public FeignResult<ContractCancelStopFlowAndOffsetResponse> contractCancelStopFlowAndOffset(@RequestBody ContractCancelStopFlowAndOffsetRequest request) {
        return Results.newSuccessResult(financialCoreDataService.contractCancelStopFlowAndOffset(request));
    }

    /**
     * 计算补录报停费用
     *
     * @param request 请求
     * @return 结果
     * @author songkf
     */
    @PostMapping("/feign/finance/core/calculateSupplementaryPauseDeviceFee")
    public FeignResult<SupplementaryPauseAmountCalculateResponse> calculateSupplementaryPauseDeviceFee(@Validated({DeviceInfoVo.SupplementaryPause.class, Default.class}) @RequestBody SupplementaryPauseAmountCalculateRequest request) {
        return Results.newSuccessResult(financialCoreDataService.calculateSupplementaryPauseDeviceFee(request));
    }

    /**
     * 生成补录报停损益
     *
     * @param request 请求
     * @return 结果
     * @author songkf
     */
    @PostMapping("/feign/finance/core/generateSupplementaryPause")
    public FeignResult<SupplementaryPauseGenerateResponse> generateSupplementaryPause(@Validated({DeviceInfoVo.SupplementaryPause.class, Default.class}) @RequestBody SupplementaryPauseGenerateRequest request) {
        return Results.newSuccessResult(financialCoreDataService.generateSupplementaryPause(request));
    }
}
